define(
	[
		'require',
		'./detail_nodedetail_track_ctrl'
	],
	function(require){
		var Controller = require('./detail_nodedetail_track_ctrl').extend({
			keyword: '',
			type: Ember.A(["交易类型","fee"]),
			selectedType: '交易类型',
			channel:Ember.A(["交易渠道","fsdf"]),
			selectedChannel: '交易渠道',
			startTime: "开始时间",
			endTime: "结束时间",
			isDone: false,
			init: function(){
				this.requireAlerts();
			},
			trackColumns: [
				{
					headerText: "序号",
					dataKey:"sequence",
					width: 60,
					allowSort: false,
					ensurePxWidth: true,
					
				},
				{
					headerText: "发起时间",
					dataKey:"firstTime",
					allowSort: false,
					ensurePxWidth: true,
					cellFormatter: function (args, colume) {
						if (args.row.type & $.wijmo.wijgrid.rowType.data) {
							var ctrl = this.get("controller");
							var date = new Date(args.row.data.firstTime);
							var  dateFor=APM.util.formatDate(date, "yyyy-MM-dd H:mm");
							var cb = $("<div class='date-text'></div>").text(dateFor);
							cb.appendTo(args.$container);
							return true;
						}
					}
				},
				{
					headerText: "交易号",
					dataKey:"transactionNum",
					allowSort: false,
					ensurePxWidth: true,
					
				},
				{
					headerText: "交易名称",
					dataKey:"transactionName",
					allowSort: false,
					ensurePxWidth: true,
					
				},
				{
					headerText: "交易类型",
					dataKey:"transactionType",
					allowSort: false,
					
				},
				{
					headerText: "客户端IP",
					dataKey:"clientIP",
					allowSort: false,
					
				},
				{
					headerText: "服务端IP",
					dataKey:"serverIP",
					allowSort: false,
					
				},
				{
					headerText: "返回码",
					dataKey:"returnCode",
					allowSort: false,
					
				},
				{
					headerText: "响应时间",
					dataKey:"responseTime",
					allowSort: false,
					
				},
				{
					headerText: "交易结果",
					dataKey:"tradingResults",
					allowSort: false,
					
				}
			],

			alerts: Ember.A(),

			requireAlerts: function() {
				var ctrl = this

				return this.store.ajax("GET", "track")
				.then(function(response){
					var alerts = response;
					if (alerts.length == 0) {
						ctrl.set("pageIndex",0);
						ctrl.set("pageSize",10);
						ctrl.set("totalRows",0);
					}else{
						ctrl.set("pageIndex",null);
						ctrl.set("pageSize",null);
						ctrl.set("totalRows",null);
					}
					
					ctrl.set("alerts", alerts);
					return response;
				});
			}
		});

		APM.BusinessDetailTradeTrackController = Controller;

		return Controller;
	}
);